package com.yizhu.zczy.system.service.impl;

import com.yizhu.zczy.common.utils.PageUtils;
import com.yizhu.zczy.common.utils.Query;
import com.yizhu.zczy.system.feign.ThirdPartyFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;


import com.yizhu.zczy.system.dao.ServiceDao;
import com.yizhu.zczy.system.entity.ServiceEntity;
import com.yizhu.zczy.system.service.ServiceService;
import org.springframework.web.multipart.MultipartFile;


@Service
public class ServiceServiceImpl extends ServiceImpl<ServiceDao, ServiceEntity> implements ServiceService {

    @Autowired
    private ThirdPartyFeignService thirdPartyFeignService;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<ServiceEntity> page = this.page(
                new Query<ServiceEntity>().getPage(params),
                new QueryWrapper<ServiceEntity>()
        );

        return new PageUtils(page);
    }

    /**
     * 保存客服信息和微信二维码图片
     * @param service
     * @param weChatPicture
     */
    @Override
    public void saveService(ServiceEntity service, MultipartFile weChatPicture) {
        String ossURLName = thirdPartyFeignService.uploadImage(weChatPicture);
        service.setUrl(ossURLName);
        this.save(service);
    }

}